package com.github.shiqiyue.app;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/***
 *
 * @author wenyao.wu
 * @date:2020/5/18
 */
public class ImageGenerator {

    public static void main(String[] args) throws FileNotFoundException, IOException {
        Integer width = 300;
        Integer height = 400;
        BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = (Graphics2D) bi.getGraphics();
        g2.setBackground(Color.WHITE);
        g2.clearRect(0, 0, width, height);
        g2.drawImage(ImageIO.read(new File("D:/a.jpg")), 20, 20, 125, 160, null);
        g2.drawImage(ImageIO.read(new File("D:/a.jpg")), 155, 20, 125, 160, null);
        g2.setColor(Color.BLACK);
        Font font=new Font(Font.MONOSPACED,Font.BOLD,14);
        g2.setFont(font);
        g2.drawString("Item:", 20, 210);
        g2.drawString("SKU:", 20, 250);
        g2.drawString("颜色:", 20, 290);
        g2.drawString("尺码:", 20, 330);
        g2.drawString("拣货码:", 20, 370);
        g2.drawString("Gildan-76000-Black-XXXL", 73, 210);
        g2.drawString("Gildan-76000-Black-XXXL", 73, 250);
        g2.drawString("Gildan-76000-Black-XXXL", 73, 290);
        g2.drawString("Gildan-76000-Black-XXXL", 73, 330);
        g2.drawString("Gildan-76000-Black-XXXL", 73, 370);
        g2.setColor(Color.lightGray);
        g2.drawRect(0,0, width-1, height-1);
        ImageIO.write(bi, "JPEG", new FileOutputStream("D:/a.jpg"));
        g2.dispose();
    }

}
